<template>
	<div class="pageBox">
		<!--币值管理-->
		<div class="management">
			<div class="current">
				当前单个币值：<span>{{coin}}</span> 个
			</div>
			单个币值：
			<a-input v-model="currency" placeholder="请输入" />
			<p>设置发放的单个币值</p>
			<!--挖掘事件：-->
			<!--<a-range-picker style="width: 300px" :defaultValue="[moment('2015/10/01', dateFormat), moment('2015/02/01', dateFormat)]" :format="dateFormat" @change="chooseTime" />-->
			<div class="buttons">
				<a-button type="primary" @click="sub">提交</a-button>
				<a-button @click="reset">重置</a-button>
			</div>
		</div>
	</div>
</template>

<script>
	import moment from 'moment';
	import 'moment/locale/zh-cn';
	moment.locale('zh-cn');
	export default {
		data() {
			return {
				dateFormat: 'YYYY/MM/DD',
				monthFormat: 'YYYY/MM',
				currency: "", //单个币值的值
				coin: '',
				// listButton:{
				//   addition:"",
				//   editor:"",
				//   cancel:""
				// }//按钮数据
			}
		},
		methods: {
			moment,
			chooseTime(e, h) {
				console.log(h)
			}, //选择完成后的时间日期
			//提交币值
			sub() {
				if(!this.currency||this.currency == 0){
					this.$message.error('币值不能为空或者为0！');
					return;
				}
				let that = this;
				this.$confirm({
					title: "操作确认",
					content: "你确定要添加币值吗？",
					onOk: () => {
						that.$ajax.post("/kmd-field-web/pm/addCoin", {
								coin: this.currency
							})
							.then(res => {
								if(res.data.statusCode == 200) {
									that.$message.success('添加币值成功!')
								} else {
									that.$message.error(res.data.message);
								}
							})
							.catch(error => {
								that.$message.error('服务器繁忙,请稍后重试!');
							})
					},
				});
			},
			//重置
			reset() {
				this.currency = ''
			}
		},
		created() {
			this.$ajax.get("/kmd-field-web/pm/detailCoin")
				.then(res => {
					this.coin = res.data.coin
				})
			//		   let titleName=sessionStorage.getItem("stairH1");
			//		   this.$ajax.get("/kmd-field-web/admin/queryBtn",{params:{"title":titleName.trim()}}).then(res=>{
			//		     for(var i=0;i<res.data.list.length;i++){
			//		       if(res.data.list[i].title=="添加"){
			//		         this.listButton.addition=res.data.list[i].title
			//		       }
			//		       if(res.data.list[i].title=="编辑"){
			//		         this.listButton.editor=res.data.list[i].title
			//		       }
			//		       if(res.data.list[i].title=="删除"){
			//		         this.listButton.cancel=res.data.list[i].title
			//		       }
			//		     }
			//		   })
		}
	}
</script>

<style scoped lang="less">
	.management {
		margin-top: 8px;
		margin-left: 28px;
		.ant-input {
			width: 158px;
		}
		p {
			margin-left: 70px;
			margin-top: 14px;
			color: rgba(0, 0, 0, 0.5);
		}
		.buttons {
			padding-left: 70px;
			margin-top: 38px;
			button {
				width: 70px;
				height: 40px;
				margin-right: 10px;
			}
		}
		.current {
			margin-bottom: 20px;
			span {
				color: red;
			}
		}
	}
</style>